{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/components/Dialogs/index.tsx\";\nimport React from 'react';\nimport { DialogItem } from \"../index\";\nimport { InputBase } from \"@mui/material\";\nimport \"./Dialogs.scss\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst Dialogs = _ref => {\n  let {\n    chatsList,\n    onSearch,\n    inputValue\n  } = _ref;\n  return /*#__PURE__*/_jsxDEV(\"div\", {\n    className: \"dialogs\",\n    children: [/*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"dialogs-item-search\",\n      children: /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"dialogs-item-search-form\",\n        children: /*#__PURE__*/_jsxDEV(InputBase, {\n          className: \"dialogs-item-search-form-input\",\n          placeholder: \"\\u041F\\u043E\\u0438\\u0441\\u043A \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\\u0430\",\n          inputProps: {\n            'aria-label': 'Поиск диалога'\n          },\n          onChange: e => onSearch && onSearch(e.target.value),\n          value: inputValue\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 13,\n          columnNumber: 21\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 12,\n        columnNumber: 17\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 11,\n      columnNumber: 13\n    }, this),\n    //Сортировка по времени\n    chatsList.items && chatsList.items.length > 0 && chatsList.items.sort((firstItem, secondItem) => {\n      var _firstItem$lastMessag, _secondItem$lastMessa;\n      if ((_firstItem$lastMessag = firstItem.lastMessage) !== null && _firstItem$lastMessag !== void 0 && _firstItem$lastMessag.createdAt && (_secondItem$lastMessa = secondItem.lastMessage) !== null && _secondItem$lastMessa !== void 0 && _secondItem$lastMessa.createdAt) {\n        var _secondItem$lastMessa2, _firstItem$lastMessag2;\n        console.log('sd', firstItem, secondItem);\n        return ((_secondItem$lastMessa2 = secondItem.lastMessage) !== null && _secondItem$lastMessa2 !== void 0 && _secondItem$lastMessa2.updatedAt ? secondItem.lastMessage.updatedAt : secondItem.lastMessage.createdAt) - ((_firstItem$lastMessag2 = firstItem.lastMessage) !== null && _firstItem$lastMessag2 !== void 0 && _firstItem$lastMessag2.updatedAt ? firstItem.lastMessage.updatedAt : firstItem.lastMessage.createdAt);\n      } else {\n        var _firstItem$lastMessag3;\n        console.log('xs', firstItem, secondItem);\n        return (_firstItem$lastMessag3 = firstItem.lastMessage) !== null && _firstItem$lastMessag3 !== void 0 && _firstItem$lastMessag3.createdAt ? firstItem.id - secondItem.id : secondItem.id - firstItem.id;\n      }\n    }).map(item => /*#__PURE__*/_jsxDEV(DialogItem, {\n      chat: item\n    }, item.id, false, {\n      fileName: _jsxFileName,\n      lineNumber: 46,\n      columnNumber: 21\n    }, this)) || /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"dialogs-item\",\n      children: [/*#__PURE__*/_jsxDEV(\"span\", {\n        className: \"dialogs-item-title\",\n        children: \"\\u0421\\u043F\\u0438\\u0441\\u043E\\u043A \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\\u043E\\u0432 \\u043F\\u0443\\u0441\\u0442\"\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 49,\n        columnNumber: 29\n      }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"dialogs-item--noData\"\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 50,\n        columnNumber: 29\n      }, this)]\n    }, void 0, true, {\n      fileName: _jsxFileName,\n      lineNumber: 48,\n      columnNumber: 25\n    }, this)]\n  }, void 0, true, {\n    fileName: _jsxFileName,\n    lineNumber: 10,\n    columnNumber: 9\n  }, this);\n};\n_c = Dialogs;\nexport default Dialogs;\nvar _c;\n$RefreshReg$(_c, \"Dialogs\");","map":{"version":3,"names":["React","DialogItem","InputBase","Dialogs","chatsList","onSearch","inputValue","e","target","value","items","length","sort","firstItem","secondItem","lastMessage","createdAt","console","log","updatedAt","id","map","item"],"sources":["/data/messenger.client/src/components/Dialogs/index.tsx"],"sourcesContent":["import React from 'react';\nimport {DialogsProps} from \"../../models/props/DialogsProps\";\nimport { ChatsListItem } from '../../models/response/ChatsListItem';\nimport {DialogItem} from \"../index\";\nimport {InputBase} from \"@mui/material\";\nimport \"./Dialogs.scss\";\n\nconst Dialogs: React.FC<DialogsProps> = ({chatsList, onSearch, inputValue}) => {\n    return (\n        <div className=\"dialogs\">\n            <div className=\"dialogs-item-search\">\n                <div className=\"dialogs-item-search-form\">\n                    <InputBase\n                        className=\"dialogs-item-search-form-input\"\n                        placeholder=\"Поиск диалога\"\n                        inputProps={{ 'aria-label': 'Поиск диалога' }}\n                        onChange={e => (onSearch && onSearch(e.target.value))}\n                        value={inputValue}\n                    />\n                </div>\n            </div>\n            {\n                //Сортировка по времени\n                (chatsList.items && chatsList.items.length > 0 && chatsList.items.sort((firstItem: ChatsListItem, secondItem: ChatsListItem):any => {\n                    if (firstItem.lastMessage?.createdAt! && secondItem.lastMessage?.createdAt!) {\n                        console.log('sd', firstItem, secondItem)\n                        return (\n                            ((secondItem.lastMessage?.updatedAt)?\n                                secondItem.lastMessage.updatedAt:\n                                secondItem.lastMessage.createdAt\n                            ) -\n                            ((firstItem.lastMessage?.updatedAt)?\n                                firstItem.lastMessage.updatedAt:\n                                firstItem.lastMessage.createdAt\n                            )\n                        );\n                    } else {\n                        console.log('xs', firstItem, secondItem)\n                        return (\n                            (firstItem.lastMessage?.createdAt!)?\n                                firstItem.id - secondItem.id:\n                                secondItem.id - firstItem.id\n                        );\n                    }\n                }).map((item) =>\n                    <DialogItem key={item.id} chat={item} />\n                )) || (\n                        <div className=\"dialogs-item\">\n                            <span className=\"dialogs-item-title\">Список диалогов пуст</span>\n                            <div className=\"dialogs-item--noData\" />\n                        </div>\n                )\n            }\n        </div>\n    );\n}\n\nexport default Dialogs;"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,SAAQC,UAAU,QAAO,UAAU;AACnC,SAAQC,SAAS,QAAO,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